import { HostBinding } from '@angular/core';
import { Component, ElementRef, AfterViewInit, OnDestroy, OnChanges, Input, Output, SimpleChange, EventEmitter } from '@angular/core';
import { MessageResult } from './messageBox';

@Component({
    selector: 'confirm',
    styleUrls: [
        './msg.scss'
    ],
    template: `
        <div class="kds-confirm" *ngIf="visible"  >
            <div class="fix-all" style="background: black;opacity: 0.4; " (click)="ignore('cancel')"></div>
            <div  class="kds-confirm-content divtcvma" style="z-index: 200;position: fixed;">
                <div class="title">{{title}}</div>
                <div class="content layout-align-center-center layout-row">
                    <span style="text-align: left;" [innerHTML]="content"></span>
                </div>
                <div class="button">
                        <button class="fail" *ngIf="!cancelHidden" (click)="cancel('cancel')">取消</button>
                        <button class="success" (click)="ok('ok')">确认</button>
                </div>
            </div>
        </div>
    `,
})
export class Confirm {
    @Input() title: string;
    @Input() content: string;
    @Input() visible: boolean;
    @Input() cancelHidden: boolean;

    @Output() onResult = new EventEmitter<any>();



    ok(rType) {
        this.visible = false;
        this.onResult.emit(rType);
    }

    cancel(rType) {
        this.visible = false;
        this.onResult.emit(rType);
    }

    ignore(rType) {
        this.visible = false;
        this.onResult.emit(rType);
    }
} 